When setting the key focus to `this._dialog`, the default button is not
automatically focused and no button has key focus.
Use the `initialKeyFocus` property of the dialog instead, and set focus
to the default button if the dialog is not already focused.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/786>
}
vfunc_focus() {
- if (this._dialog)
- this._dialog.grab_key_focus();
+ if (!this._dialog)
+ return;
+
+ const keyFocus = global.stage.key_focus;
+ if (!keyFocus || !this._dialog.contains(keyFocus))
+ this._dialog.initialKeyFocus.grab_key_focus();
}
});